<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
</head>

<body>
    <!-- 
        请补全JavaScript代码，要求将字符串参数URL中的参数解析并以对象的形式返回。
        输入：getParams('https://nowcoder.com/online?id=1&salas=1000')
        输出：{id:1, salas: 100}
     -->
    <script>
        const _getParams = (url) => {
            // 补全代码 url.slice(url.lastIndexOf('?') + 1) -> id=1&salas=1000
            let splitUrl = url.slice(url.lastIndexOf('?') + 1).split('&')
            console.log(splitUrl)
            let obj = {}
            splitUrl.map(n => {
                let [key, value] = n.split('=')
                obj[key] = value
            })
            console.log(obj)
            return obj
        }
        _getParams('https://nowcoder.com/online?id=1&salas=1000')
    </script>
</body>

</html>